package com.sky.controller.admin;


import com.sky.constant.MessageConstant;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "店铺相关接口")
@RequestMapping("/admin/shop")
@Log4j2
public class shopController {
    @Autowired
    RedisTemplate redisTemplate;

    @PutMapping("/{status}")
    @ApiOperation("设置营业状态")
    public Result setStatus(@PathVariable("status") Integer status){
        log.info(status == 1 ? "营业状态" : "打烊了");
        redisTemplate.opsForValue().set(MessageConstant.SHOPSTATUS, status);
        return Result.success();
    }
    @GetMapping("/status")
    @ApiOperation("获取营业状态")
    public Result getStatus(){
        Integer shopstatus = (Integer) redisTemplate.opsForValue().get(MessageConstant.SHOPSTATUS);
        return Result.success(shopstatus);
    }

}
